<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="utf-8" />
		<title>最家</title>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<link rel="stylesheet" type="text/css" href="css/myorder.css" />
		<script src="X-admin/js/jquery.js"></script>
		<script src="js/public.js"></script>

	</head>
	<body>
		<!------------------------------head------------------------------>
		<div class="head" id="top">
		</div>
		<script src="js/common.js"></script>
		<!------------------------------idea------------------------------>
		<div class="address mt">
			<div class="wrapper clearfix">
				<a href="#" class="fl">首页</a>
				<span>/</span>
				<a href="mygxin.html">个人中心</a>
				<span>/</span>
				<a href="myorderq.html" class="on">我的订单</a>
			</div>
		</div>
		
		<!------------------------------Bott------------------------------>
		<div class="Bott">
			<div class="wrapper clearfix">
				<div class="zuo fl">
					<h3>
						<a href="#"><img id="person-img" style="border-radius: 60%;height: 100px;width: 100px"/></a>
						<p class="clearfix"><span id="username">[羊羊羊]</span><span class="fr">您好！</span></p>
					</h3>
					<div>
						<h4>我的订单</h4>
						<ul>
							<li><a href="myorderq.html">订单中心</a></li>
						</ul>
						<h4>个人中心</h4>
						<ul>
							<li ><a href="mygxin.html">我的评价</a></li>
							<li ><a href="collection.html">我的收藏</a></li>
							<li><a href="message.html">系统消息</a></li>
						</ul>
						<h4>账户管理</h4>
						<ul>
							<li><a href="mygrxx.html">个人信息</a></li>
							<li><a href="remima.html">修改密码</a></li>
						</ul>
					</div>
				</div>
				<div class="you fl">
					<div class="my clearfix">
						<h2 class="fl">我的订单</h2>
						<a href="#" class="fl">请谨防钓鱼链接或诈骗电话，了解更多&gt;</a>
					</div>
					<div class="dlist clearfix">
						<ul class="fl clearfix" id="wa">
							<li class="on"><a href="myorderq1.html">待支付</a></li>
							<li ><a href="myorderq2.html">使用中</a></li>
							<li ><a href="myorderq.html">已完成</a></li>
							<li><a href="myorderq3.html">已失效</a></li>

							<!--							<li><a href="#2">已关闭</a></li>-->
						</ul>
<!--						<form action="#" method="get" class="fr clearfix">-->
<!--							<input type="text" name="" id="" value="" placeholder="请输入商品名称、订单号" />-->
<!--							<input type="button" name="" id="" value="" />-->
<!--						</form>-->
					</div>

<div id="orderList">
<!--					<div class="dkuang">-->
<!--						<p class="one">有效订单</p>-->
<!--						<div class="word clearfix">-->
<!--							<ul class="fl clearfix">-->
<!--								<li>2016年12月1日 18:53</li>-->
<!--								<li>杨小黄</li>-->
<!--								<li>订单号:5160513358520018</li>-->
<!--								<li>在线支付</li>-->
<!--							</ul>-->
<!--							<p class="fr">订单金额：<span>99.00</span>元</p>-->
<!--						</div>-->
<!--						<div class="shohou clearfix">-->
<!--							<a href="#" class="fl"><img src="img/g1.jpg"/></a>-->
<!--							<p class="fl"><a href="#">家用创意菜盘子圆盘 釉下彩复古</a><a href="#">¥99.00×1</a></p>-->
<!--							<p class="fr">-->
<!--								<a href="myprod.html">待评价</a>-->
<!--								<a href="orderxq.html">订单详情</a>-->
<!--							</p>-->
<!--						</div>-->
<!--					</div>-->



				</div>
			</div>
		</div>
		</div>
		<!--返回顶部-->
		<div class="gotop">
			<a href="cart.html">
			<dl>
				<dt><img src="img/gt1.png"/></dt>
				<dd>去购<br />物车</dd>
			</dl>
			</a>
			<a href="#" class="dh">
			<dl>
				<dt><img src="img/gt2.png"/></dt>
				<dd>联系<br />客服</dd>
			</dl>
			</a>
			<a href="mygxin.html">
			<dl>
				<dt><img src="img/gt3.png"/></dt>
				<dd>个人<br />中心</dd>
			</dl>
			</a>
			<a href="#" class="toptop" style="display: none">
			<dl>
				<dt><img src="img/gt4.png"/></dt>
				<dd>返回<br />顶部</dd>
			</dl>
			</a>
			<p>400-800-8200</p>
		</div>
		<!--footer-->
		<div class="footer">
			<div class="top">
				<div class="wrapper">
					<div class="clearfix">
						<a href="#2" class="fl"><img src="img/foot1.png"/></a>
						<span class="fl">7天无理由退货</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="img/foot2.png"/></a>
						<span class="fl">15天免费换货</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="img/foot3.png"/></a>
						<span class="fl">满599包邮</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="img/foot4.png"/></a>
						<span class="fl">手机特色服务</span>
					</div>
				</div>
			</div>
			<p class="dibu">最家家居&copy;2013-2017公司版权所有 京ICP备080100-44备0000111000号<br />
			违法和不良信息举报电话：188-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>
		</div>
		<script src="js/user.js" type="text/javascript" charset="utf-8"></script>
		<script >
			var Address_Prefix = "http://localhost:9200/api-person";
			find();
			async 	function  find(){
				$.ajax({
					url:Address_Prefix+'/order/findUnpaidOrder',
					data:{userid:sessionStorage.getItem("userid"),pagees:1,limits:10},
					dataType:'json',
					type:'get',
					success:function (data){
						data = data.data;
						let obj =$("#orderList");
						let innerHtml = "";
						console.log(data);
						for (let i = 0; i<data.length; i++) {
							let orcode = data[i].orcode;
							let datec = data[i].crdate;
							innerHtml+="<div class=\"dkuang\">\n" +
									"\t\t\t\t\t\t<p class=\"one\">"+data[i].stname+"</p>\n" +
									"\t\t\t\t\t\t<div class=\"word clearfix\">\n" +
									"\t\t\t\t\t\t\t<ul class=\"fl clearfix\">\n" +
									"\t\t\t\t\t\t\t\t<li>"+data[i].crdate+"</li>\n" +
									"\t\t\t\t\t\t\t\t<li>订单号:"+data[i].orcode+"</li>\n" +
									"\t\t\t\t\t\t\t\t<li>在线支付</li>\n" +
									"\t\t\t\t\t\t\t</ul>\n" +
									"\t\t\t\t\t\t\t<p class=\"fr\">订单金额：<span>"+ data[i].prices+"</span>元</p>\n" +
									"\t\t\t\t\t\t</div>\n" +
									"\t\t\t\t\t\t<div class=\"shohou clearfix\">\n" +
									"\t\t\t\t\t\t\t<a href=\"#\" class=\"fl\"><img src=\""+data[i].topimg +"\"/></a>\n" +
									"\t\t\t\t\t\t\t<p class=\"fl\"><a href=\"#\"></a><a href=\"#\">¥"+data[i].unitpr+"*"+data[i].letime+"*"+ data[i].reduce+"</a></p>\n" +
									"\t\t\t\t\t\t\t<p class=\"fr\">\n" +
									"\t\t\t\t\t\t\t\t<a>订单折扣:"+ data[i].reduce+"</a>\n" +
									// "\t\t\t\t\t\t\t\t<a onclick='goPay("+data[i].userid+","+"&quot;"+orcode+"&quot;"+")'>去支付</a>\n" +
									"\t\t\t\t\t\t\t\t<a onclick='goPay("+"&quot;"+data[i].stname+"&quot;"+","+data[i].prices+","+"&quot;"+orcode+"&quot;"+")'>去支付</a>\n" +
									"\t\t\t\t\t\t\t\t<a onclick='cancelOrder("+data[i].userid+","+"&quot;"+orcode+"&quot;"+")'>取消订单</a>\n" +
									"\t\t\t\t\t\t\t\t<a id='time"+i+"'></a>\n" +
									"\t\t\t\t\t\t\t\t<h1></h1>\n" +
									"\t\t\t\t\t\t\t</p>\n" +
									"\t\t\t\t\t\t</div>\n" +
									"\t\t\t\t\t</div>";
							timer(i,datec);

						}
						obj.html(innerHtml);
					}
				});
				return false;
			}

			goPay = function (stname,prices,orcode) {
				sessionStorage.setItem("orcode", orcode);
				sessionStorage.setItem("stname",stname);
				sessionStorage.setItem("prices",prices);
				window.open('../ZBestPC/pay/pay.html')

				// $.ajax({
				// 	url:Address_Prefix+'/order/completePay',
				// 	data:{userid:sessionStorage.getItem("userid"),orcode:orcode},
				// 	dataType:'json',
				// 	type:'post',
				// 	success:function (data){
				// 		if(data.code==0){
				// 			window.alert("支付成功！")
				// 		}
				// 	}
				// })
				// return false;


			}



				function cancelOrder(userid, orcode) {
					$.ajax({
						url: Address_Prefix + '/order/cancelOrder',
						data: {userid: userid, orcode: orcode, enable: 0},
						dataType: 'json',
						type: "post",
						success: function (data) {
							if (data.code == 0) {
								window.alert("取消成功！")
							} else {
								window.alert("取消失败！")
							}
						}
					});
					return false;
				}

				//倒计时
			function timer(i,datec){
				console.log(datec);
				//获取到期时间的毫秒数
				let date = new Date(datec);
				console.log(date)
				let time = date.getTime() + 1800 * 1000;

				//获取到当前时间的毫秒数
				let date1 = new Date();
				let times1 = date1.getTime();

				//获取两者的差值
				let times = time - times1;

				//将差值放入到倒计时方法中
				resetTime(times / 1000);

				//倒计数方法
				function resetTime(time) {
					var timer = null;
					var t = time;
					var m = 0;
					var s = 0;
					var $span = $('#timer span');
					m = Math.floor(t / 60 % 60);
					m < 10 && (m = '0' + m);
					s = Math.floor(t % 60);

					function countDown() {
						s--;
						s < 10 && (s = '0' + s);
						if (s.length >= 3) {
							s = 59;
							m = "" + (Number(m) - 1);
						}
						if (m.length >= 3) {
							m = '00';
							s = '00';
							clearInterval(timer);
						}
						$("#time"+i).html("支付倒计时："+m+"分"+s+"秒");
					}
					timer = setInterval(countDown, 1000);
				}
			}
		</script>

	</body>
</html>
